<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" >

	<h:form id="frm2">	
		<p:growl id="msgs2" showDetail="true" />
		<p:panel id="mainPanel" header="【第二步】详细信息录入" style="margin-bottom:5px">
			<h:panelGrid id="detailGrid" columns="10" cellspacing="10" >					
				<p:commandButton id="detailBtn" value="选择采购订单物料..."  type="button" icon="fa fa-fw fa-search-plus" 
					onclick="PF('ovpl2').loadContents();" />
				<!-- 选择采购订单详情 -->
			    <p:overlayPanel for="detailBtn"  widgetVar="ovpl2"  hideEffect="fade" dynamic="true" 
			   				showCloseIcon="false" style="width:1000px"  >
			        <p:dataTable var="srow" value="#{receiptMB.bmePurchDetails}"  
			        	paginator="true" paginatorPosition="bottom" emptyMessage="没有记录"
			         	rowKey="#{srow.id}"  selection="#{receiptMB.selectedPurchDetails}" >
			         	
						<p:column selectionMode="multiple" style="width:16px;text-align:center"/>
			           <p:column headerText="物料编号">
			               <h:outputText value="#{srow.bmeMaterial.id}" />
			           </p:column>
			           <p:column headerText="物料名称">
			               <h:outputText value="#{srow.bmeMaterial.mdesc}" />
			           </p:column>
			           <p:column headerText="规格">
			               <h:outputText value="#{srow.bmeMaterial.mmodel}" />
			           </p:column>
			           <p:column headerText="单位">
			               <h:outputText value="#{srow.munit}" />
			           </p:column>
			           <p:column headerText="数量">
			               <h:outputText value="#{srow.mquantity}" />
			           </p:column>
			           <p:column headerText="单价">
			               <h:outputText value="#{srow.mprice}" />
			           </p:column>
			           <p:column headerText="金额">
			               <h:outputText value="#{srow.mamount}" />
			           </p:column>
			           <p:column headerText="数量片">
			               <h:outputText value="#{srow.processQuantity}" />
			           </p:column>
			           <p:column headerText="加工规格">
			               <h:outputText value="#{srow.processSpeci}" />
			           </p:column>
			           <p:column headerText="加工工艺">
			               <h:outputText value="#{srow.processTeck}" />
			           </p:column>
		
			       </p:dataTable>
				   <h:panelGrid columns="3" cellspacing="10">					  
						<p:commandButton value="确认"	icon="ui-icon-check"  oncomplete="PF('ovpl2').hide();"  
							action="#{receiptMB.saveDetail}" update=":frm2">
						</p:commandButton>	
					</h:panelGrid>
			    </p:overlayPanel>

				<p:commandButton value="生成合同订单已发货量" icon="ui-icon-plus" 
	           		process="@this" update=":frm2:msgs2" 
                 	actionListener="#{receiptMB.genShipAmount}"  >					
				</p:commandButton>
			</h:panelGrid>
		
			<p:dataTable id="rdt" value="#{receiptMB.vod}"  var="row"  rowIndexVar="rowNum"
				resizableColumns="true" liveResize="true" 
				editable="true"  style="margin-bottom:5px"
				paginator="true" paginatorPosition="bottom" rows="8" 
				emptyMessage="没有记录" > 
				<p:ajax event="rowEdit" listener="#{receiptMB.onRowEdit}"
					update=":frm2:msgs2" />
				<p:ajax event="rowEditCancel"	listener="#{receiptMB.onRowCancel}"
					update=":frm2:msgs2" />					
				<p:column headerText="No." width="20" >
					#{rowNum+1}
				</p:column>				
				<p:column headerText="物料编号" sortBy="#{row.bmeMaterial.id}" width="100" >
					<h:outputText value="#{row.bmeMaterial.id}"  />
				</p:column>
				<p:column headerText="物料描述" width="100" >
					<h:outputText value="#{row.bmeMaterial.mdesc}" />
				</p:column>
	            <p:column headerText="规格" width="80">
	                <h:outputText value="#{row.bmeMaterial.mmodel}" />
	    		</p:column>
				<p:column headerText="数量" width="40" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.mquantity}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.mquantity}"  /></f:facet>
					</p:cellEditor>
				</p:column>
	            <p:column headerText="数量片" width="60">
	            	<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.processQuantity}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.processQuantity}"  /></f:facet>
					</p:cellEditor>
	            </p:column>
	            <p:column headerText="加工规格" width="80">
	                <h:outputText value="#{row.processSpeci}" />
	            </p:column>
	            <p:column headerText="加工工艺" width="80">
	                <h:outputText value="#{row.processTeck}" />
	            </p:column>				
				<p:column headerText="备注" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.remarks}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.remarks}" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="签收数量" width="60" >
					<h:outputText value="#{row.squantity}" />
				</p:column>
				<p:column headerText="破损数量" width="60" >
					<h:outputText value="#{row.dquantity}" />						
				</p:column>
				<p:column headerText="丢失数量" width="60" >
					<h:outputText value="#{row.lquantity}" />						
				</p:column>								
				<p:column headerText="修改" style="width:32px">
					<p:rowEditor editTitle="修改" cancelTitle="取消" saveTitle="保存" />
				</p:column>
				<p:column headerText="删除" style="width:32px">
					<p:commandButton icon="ui-icon-minus"   title="删除"  immediate="true"
						action="#{receiptMB.delDetail}" update=":frm2">
						<f:setPropertyActionListener value="#{row}"
							target="#{receiptMB.selectedd}" />
						<p:confirm header="确认" message="你确定删除此记录信息？" icon="ui-icon-alert" />
					</p:commandButton>	
				</p:column>
				
			</p:dataTable>    
		</p:panel>		
	</h:form>	
		
	<!-- confirm to del product -->
    <p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
        <p:commandButton value="确认" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
        <p:commandButton value="取消" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
    </p:confirmDialog>
				
</ui:composition>
